{% extends 'sys_templates/public/seed_base.html' %}
{% block head %}
    <script charset="utf-8" src="{{ url_for('static',filename='lib/kindeditor/kindeditor-all.js') }}"></script>
    <script charset="utf-8" src="{{ url_for('static',filename='lib/kindeditor/lang/zh-CN.js') }}"></script>
    <link rel="stylesheet" href="{{ url_for('static',filename='lib/kindeditor/themes/default/edit_style.css') }}"/>
{% endblock %}
{% block content %}
    <form class="layui-form">
        {% for foo in form %}
            <div class="layui-form-item">
                <label class="layui-form-label">{{ foo.label }}</label>
                <div class="layui-input-block">
                    {{ foo }}
                </div>
            </div>
        {% endfor %}
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <a class="layui-btn" href="javascript:;" onclick="content_submit()">提交保存</a>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </form>
{% endblock %}
{% block footer_js %}
    <script>
        layui.use(['laydate', 'form', 'layer'], function () {
            laydate = layui.laydate;//日期插件
            var end = {
                min: laydate.now()
                , max: '2099-06-16 23:59:59'
                , istoday: false
            };
            /*日期-结束*/  // 日期列表
            document.getElementById('ad_end_date').onclick = function () {
                end.elem = this;
                laydate(end);
            }
        });
        $(function () {
            var time = getNowFormatDate();
            {% if title=="新建广告位" %}
            $("input[name='ad_end_date']").val(time);
            {% endif %}
        });

        // 获取当前日期
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            return year + seperator1 + month + seperator1 + strDate;
        }
        KindEditor.options.filterMode = false;
            KindEditor.ready(function (K) {
                window.editor = K.create('#ad_code', {
                    uploadJson: '{{ url_for('cms_bp.upload') }}',
                    allowFileManager: false,
                    wellFormatMode: true,
                    resizeType: 1,
                    formatUploadUrl: false,
                    width:'500px',

                });
            });
    </script>
{% endblock %}